package com.gec.zhs.exception;

import com.gec.zhs.utils.Result;
import com.gec.zhs.utils.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zhs
 * @version 1.0
 * @date 2025-08-25
 * @description
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result<String> error(Exception e) {
        e.printStackTrace();
        return Result.fail(ResultCodeEnum.SERVICE_ERROR);
    }

    @ExceptionHandler(ZhsException.class)
    public Result<String> error(ZhsException e) {
        e.printStackTrace();
        return Result.fail(e.getCode(), e.getMsg());
    }

}
